var layer;
var element;
var form;
var laydate;
var table;
var upload;
layui.use(['element','layer','laydate','form','table'], function(){
    layer = layui.layer;
    element = layui.element;
    form = layui.form;
    laydate = layui.laydate;
    table = layui.table;
    upload = layui.upload;
    load();
    selAuditList(2,"","");
    //但是，如果你的HTML是动态生成的，自动渲染就会失效
    //因此你需要在相应的地方，执行下述方法来进行渲染
    form.render();
})
/**
 *  按钮  点击事件 刷新页面  返回  检索
 * */
function load() {
    //搜索按钮
    $("#indexBtn").bind('click', function () {
        //账号
        var account = $("input[name=account]").val();
        //名称
        var nickname = $("input[name=nickname]").val();

        selAuditList(2,account, nickname);
    })
    let i = true;
    //收起筛选，放下
    $("#put_screen").bind('click', function () {
        if (i) {//判断i如果为true，则隐藏搜索，如果为false则展示搜索
            $("#selIndex").attr("style", "display:none;");
            $(".div_list_title").attr('style', "margin-top: -84px;")
            $("#put_screen").html("<i class='layui-icon layui-icon-up ayui-font-9'></i>打开筛选")
            i = false;
        } else {
            $("#selIndex").attr("style", "dispaly:block;");
            $(".div_list_title").attr('style', "margin-top: 0px;")
            $("#put_screen").html("<i class='layui-icon layui-icon-down ayui-font-9'></i>收起筛选")
            i = true;
        }
    })
    //刷新页面按钮
    $(".tit_btn").bind('click', function () {
        location.reload();
    })
    $("#retrieval").bind('click', function () {
        retrieval();
    })
}

//删除订单
function delAuditUser(id) {
    $.post("/personnel/delReceptionLoginLog", {id: id}, function (res) {
        if(res.data==1){
            layer.msg('删除成功');
        }else{
            layer.msg('删除成功');
        }
        selAuditList(2,"","");
    });
}
//查询
function selAuditList(ind,account,nickname){
    $.post("/personnel/selBackstageLoginLog", {ind:ind,account:account,nickname:nickname}, function (res) {
        userTab(res.data);
    });
}
//layui-table
function userTab(item){
    table.render({
        elem:"#userListTab",//容器
        title:"商品订单待付款列表",
        data:item,
        toolbar:true,
        page:true,
        cols:cols
    });
}
//layui-table格式
var cols=[[//定义列
    {type:'checkbox',align:'center',width:40},//复选框靠左
    {title:'序号',align:'center',width:60,templet:function(data){
            return data.LAY_INDEX;
        }},
    {field:"login_location",title:"登陆地址",align:'center',width:160},
    {field:"login_ip",title:"登录ip",align:'center',width:160},
    {field:"login_state",title:"订单来源",align:'center',width:160,templet:function(data){
            if(data.login_state==2){//2为登陆成功
                return "登陆成功";
            }else if(data.login_state==3){//3为登陆失败
                return "登陆失败"
            }else{
                return "其他"
            }
        }},
    {field:"login_date",title:"登陆时间",align:'center',width:180,templet:function(data){
            return renderTime(data.login_date)
        }},
    {field:"true_name",title:"名称",align:'center',width:160},
    {field:"account",title:"账号",align:'center',width:160},
    {field:"",title:"操作",align:'center',templet:function(data){
            return "<a style='color:#009688;cursor:pointer;' onclick='delAuditUser(\""+data.id+"\")'>删除</a> ";
        }}
]];